package chpt05;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class CountMap {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Map<String, Integer> cm = new TreeMap<String, Integer>();
		while (in.hasNext()) {
			String str = in.next();
			if (str.equals("!!!!!"))
				break;
			else if (!cm.containsKey(str))
				cm.put(str, 1);
			else {
				int n = (int) cm.get(str);
				cm.put(str, n + 1);
			}
		}
		System.out.println(cm.size());
		List<Map.Entry<String, Integer>> arrayList = new ArrayList<Map.Entry<String, Integer>>(cm.entrySet());
		Collections.sort(arrayList, new Comparator<Map.Entry<String, Integer>>() {
			public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
				return ((Integer) o2.getValue()) - ((Integer) o1.getValue());
			}
		});
		int n=10;
		for (Map.Entry<String, Integer> entry : arrayList) {
			if(n--==0)
				break;
			String key = entry.getKey();
			Integer value = entry.getValue();
			System.out.println(key + "=" + value);
		}

		in.close();
	}

}
